<?php
include_once "define.php";
include_once "config.php";
include_once "utils.php";

//$idClub = $_POST['idClub'];
$idClub = 1;

$url    = "http://pesstatsdatabase.com/PSD/Club.php?Championship=" . $idClub;
$html   = Util::getContentsCurl($url);
$dom    = new DOMDocument();
@$dom->loadHTML($html);

$table  = $dom->getElementsByTagName('table');
$tr     = $table->item(1)->getElementsByTagName('tr');
$html   = '<table border="1" cellspacing="1" cellpadding="5">';
$html .= '<tr>';
$rowDisplay = 0;
for ($j=6, $len=$tr->length; $j<$len; $j++)
{
    $td = $tr->item($j)->getElementsByTagName('td');
    for($i=0, $s=$td->length; $i<$s; $i++)
    {
        $a = $td->item($i)->getElementsByTagName('a');
        $href = "";
        foreach ($a as $att)
        {
            if ($att->hasAttribute('href'))
            {
                $href = $att->getAttribute('href');
                break;
            }
        }
        $img = $a->item(0)->getElementsByTagName('img');
        $src = "";
        foreach ($img as $att)
        {
            if ($att->hasAttribute('src'))
            {
                $src = $att->getAttribute('src');
                break;
            }
        }
        $name = $a->item(0)->nodeValue;
        $html .= '<td align="center">';
        $html .= '<img src="' . HGA_PATH_HOME_PSD . $src . '" width="50" height="50" /> <br /> ' . $name;
        $html .= '</td>';
        $rowDisplay++;
        if ($rowDisplay % 10 == 0)
        {
            $html .= '</tr>';
            $html .= '<tr>';
        }
    }
}
$html .= '</tr>';
$html .= '</table>';
echo $html;
//echo json_encode($arr);

